Component({
    options:{
        styleIsolation: 'apply-shared',
    },
    properties: {
        coupons:{type:Array, value:[]},  // 可用优惠券列表
    },
    data: {
        show:false,
    },
    lifetimes:{

    },
    methods: {
        /**
         * 弹窗显示
         */
        open: function () {
            this.setData({
                show: true,
            })
        },
        close(){
            this.setData({
                show:false,
            })
        },
        couponClick(e){
            const {index} = e.currentTarget.dataset
            const {coupons} = this.data
            this.triggerEvent("change", {
                isUseCoupon:true,
                coupon:coupons[index],
                user_coupon_id:coupons[index].id
            })
            this.close()
        },
        noUseClick(){
            this.triggerEvent("change", {
                isUseCoupon:false,
                coupon:null,
                user_coupon_id:0
            })
            this.close()
        }
    }
});
